// createRouter：创建router实例对象
// createWebHistory：创建history模式的路由
import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    // path和component对应关系的位置
    routes: [
        {
            name: 'home',
            path: '/',
            redirect: '/bottom/risk'
        },
        {
            name: 'side',
            path: '/side',
            component: () => import('@/components/Side/index.vue'),
            children: [
                // 二级路由，path分配，前面不要有 /
                {
                    name: 'side_device',
                    path: 'device',
                    component: () => import('@/views/Device/Side/index.vue')
                },
                {
                    name: 'side_product',
                    path: 'product',
                    component: () => import('@/views/Product/Side/index.vue')
                }
            ]
        },
        {
            name: 'bottom',
            path: '/bottom',
            component: () => import('@/components/Bottom/index.vue'),
            children: [
                // 二级路由，path分配，前面不要有 /
                {
                    name: 'bottom_device',
                    path: 'device',
                    component: () => import('@/views/Device/Bottom/index.vue')
                },
                {
                    name: 'bottom_product',
                    path: 'product',
                    component: () => import('@/views/Product/Bottom/index.vue')
                },
                {
                    name: 'bottom_risk',
                    path: 'risk',
                    component: () => import('@/views/Risk/Bottom/index.vue')
                }
            ]
        }
    ],
    // 路由滚动行为定制
    scrollBehavior() {
        return {
            top: 0
        }
    }
})

export default router
